package com.yuanfengerp.Analysis.controller;

import com.yuanfengerp.Analysis.model.Department;
import com.yuanfengerp.Analysis.service.IDepartmentService;
import com.yuanfengerp.publicUtil.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController
@CrossOrigin
public class DepartmentController {
    @Autowired
    private IDepartmentService departmentService;

    /**
     *  新增部门
     * @param department
     * @return
     */
    @PostMapping("/insertDepartment")
    public Result<Department> addDepartment(@RequestBody Department department){
        return departmentService.insertDepartment(department);
    }
    /**
     *  查询部门
     * @return
     */
    @PostMapping("/getDepartmentList")
    public ArrayList<Department> getDepartmentList(Integer pageSize, Integer offset){
        return departmentService.getDepartmentList(pageSize , offset);
    }
    @PostMapping("/getDepartment")
    public ArrayList<Department> getDepartment(String department_Number){
        return departmentService.getDepartment(department_Number);
    }
    @PostMapping("/updateDepartment")
    public Result<Department> updateDepartment(@RequestBody Department department){
        return departmentService.updateDepartment(department);
    }
}
